﻿Public Class FormStoreEditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        If Me.txtStoreName.Text = "" Then
            MsgBox("Please input Store name!")
            Me.txtStoreName.Focus()
            Return
        End If

        Cmd.Parameters("@StoreName") = Me.txtStoreName.Text
        If Me.txtStoreId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Store VALUES(@StoreName,1);")
        Else
            Cmd.Parameters("@StoreId") = txtStoreId.Text
            Cmd.ExecuteNonQuery("UPDATE Store SET StoreName=@StoreName WHERE StoreId=@StoreId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
End Class